/*
 * =====================================================================================
 *
 *       Filename:  Lift.cc
 *
 *    Description:
 *
 *        Version:  1.0
 *        Created:  01/04/2022 03:13:01 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  first_name last_name (fl), fl@my-company.com
 *        Company:  my-company
 *
 * =====================================================================================
 */
#include "Lift.h"
#include <iostream>
#include "Log.h"

using std::string;
static const string TAG = "Lift";

using std::cout;
using std::endl;

Lift::Lift(void) {
    this->m_state = 0;
}

Lift::~Lift(void) {
}

void Lift::SetState(int state) {
    this->m_state = state;
}

void Lift::Open() {
    LogI("In");

    switch (this->m_state) {
    case OPENING_STATE:
        break;

    case CLOSING_STATE:
        this->OpenWithoutLogic();
        this->SetState(OPENING_STATE);
        break;

    case RUNNING_STATE:
        break;

    case STOPPING_STATE:
        this->OpenWithoutLogic();
        this->SetState(OPENING_STATE);
        break;
    }
}

void Lift::Close() {
    LogI("In");

    switch (this->m_state) {
    case OPENING_STATE:
        this->CloseWithoutLogic();
        this->SetState(CLOSING_STATE);
        break;

    case CLOSING_STATE:
        break;

    case RUNNING_STATE:
        break;

    case STOPPING_STATE:
        break;
    }
}

void Lift::Run() {
    LogI("In");

    switch (this->m_state) {
    case OPENING_STATE:
        break;

    case CLOSING_STATE:
        this->RunWithoutLogic();
        this->SetState(RUNNING_STATE);
        break;

    case RUNNING_STATE:
        break;

    case STOPPING_STATE:
        this->RunWithoutLogic();
        this->SetState(RUNNING_STATE);
        break;
    }
}

void Lift::Stop() {
    LogI("In");

    switch (this->m_state) {
    case OPENING_STATE:
        break;

    case CLOSING_STATE:
        this->StopWithoutLogic();
        this->SetState(CLOSING_STATE);
        break;

    case RUNNING_STATE:
        this->StopWithoutLogic();
        this->SetState(CLOSING_STATE);
        break;

    case STOPPING_STATE:
        break;
    }
}

void Lift::OpenWithoutLogic() {
    LogI("%s", "电梯门开启...");
}

void Lift::CloseWithoutLogic() {
    LogI("%s", "电梯门关闭...");
}

void Lift::RunWithoutLogic() {
    LogI("%s", "电梯上下跑起来...");
}

void Lift::StopWithoutLogic() {
    LogI("%s", "电梯停止了...");
}
